Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Powerset::fold specialization #765

Merged
merged 3 commits into from
Sep 28, 2023

Conversation

Philippe-Cholet
Copy link
Member

@Philippe-Cholet Philippe-Cholet commented Sep 28, 2023

Related to #755

Rank Description powerset_0_fold (µs) powerset_1_fold (µs) powerset_2_fold (µs) powerset_4_fold (µs) powerset_8_fold (µs) powerset_12_fold (µs)
3 no specialization [321.26 322.12 323.18] [395.73 396.62 397.61] [353.65 355.59 357.87] [333.72 334.66 335.72] [321.30 321.79 322.31] [318.88 319.67 320.71]
1 wins currently [312.58 312.94 313.29] [375.18 375.65 376.12] [330.77 331.83 332.96] [298.66 299.17 299.72] [289.46 289.81 290.18] [289.31 289.68 290.16]
2 With (k+1..=n).fold [320.78 322.00 323.43] [383.65 384.39 385.30] [349.08 350.11 351.12] [315.60 316.55 317.63] [304.82 305.70 306.59] [296.88 297.81 299.03]

So it's 10% faster than without specialization for powerset_{4,8,12}_fold (and 3% to 7% for n=0,1,2).
And (it.k() + 1..=it.n()).fold makes it (intermediary) slower (so it's not pushed here).

Once Combinations::fold is implemented, it should be even faster.

EDIT: Sorry, the table does not render well.

Philippe-Cholet and others added 2 commits September 22, 2023 23:38
Reset between `&mut Combinations::fold` calls.
Copy link
Member

@jswrenn jswrenn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Can you add a specializations test? See the comment here for guidance: #764 (review)

Truncated to be fast enough.
@jswrenn jswrenn added this pull request to the merge queue Sep 28, 2023
Merged via the queue into rust-itertools:master with commit d6d2a14 Sep 28, 2023
8 checks passed
@jswrenn jswrenn added this to the next milestone Sep 28, 2023
@Philippe-Cholet Philippe-Cholet deleted the powerset-fold branch September 28, 2023 19:33
@jswrenn jswrenn mentioned this pull request Nov 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants